

help:
	@echo "见 makefile 文件"

# ========== docker build begin ===========
# 自动检测并映射架构名称
UNAME_M := $(shell uname -m)

# 架构映射
ifeq ($(UNAME_M),x86_64)
    ARCH := x86_64
    DOCKERFILE := Dockerfile_x86_64
else ifeq ($(UNAME_M),aarch64)
    ARCH := aarch64
    DOCKERFILE := Dockerfile_aarch64
else ifeq ($(UNAME_M),arm64)
    ARCH := aarch64
    DOCKERFILE := Dockerfile_aarch64
else
    $(error Unsupported architecture: $(UNAME_M))
endif

docker-build:
	@echo "Building for $(ARCH) architecture..."
	docker build -f $(DOCKERFILE) --build-arg ARCH_NAME=$(ARCH) -t myproject:latest .

check-arch:
	@echo "Current architecture: $(shell uname -m)"
	@echo "Mapped ARCH: $(ARCH)"
	@echo "Dockerfile: $(DOCKERFILE)"

docker-build-x86_64:
	docker build -f Dockerfile_x86_64 --build-arg ARCH_NAME=x86_64 -t myproject:latest .

docker-build-aarch64:
	docker build -f Dockerfile_aarch64 --build-arg ARCH_NAME=aarch64 -t myproject:latest .

docker-run:
	docker run -itd --name myproject -p 8080:8080 myproject:latest

docker-log:
	docker logs -f myproject

docker-clean:
	docker rm -f myproject

docker-exec:
	docker run -it --entrypoint /bin/bash myproject

# ========== docker build end ===========


# todo 检测是否已存在 .env 。提示覆盖？？？
init:
	@echo "从 env.example 生成 .env"
	cp env.example .env
	@echo ".env 文件已生成"

cleanUpdate:
	./boot.sh cleanUpdate ./fdemo

build:
	./boot.sh build ./fdemo

run:
	./boot.sh run ./fdemo

start: run

restart: build run

# bash -c "exit 1"; echo "Build exit status: $?"




restart: build start

exec:
	docker compose exec -it cangjie /bin/bash

outer-restart:
	docker compose exec -it cangjie /bin/bash -c -l "cd /app && make restart"




